package cn.springboot.erp.config;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class WebSwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("java") // 分组
                .apiInfo(api()) // 设置接口文档的基本信息
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .build();
    }

    // 设置接口文档的基本信息
    private ApiInfo api(){
        return new ApiInfoBuilder()
                .title("java前后端分离项目接口文档")  // 设置接口文档的标题
                .description("这是一个前后端分离项目<br>" +
                        "前端技术：Vue+Element-UI+Axios<br>" +
                        "后端技术：SpringBoot+Mybatis-Plus+Shiro<br>" +
                        "数据库：MySQL+Redis") // 设置接口文档的描述信息
                .version("1.0")  //设置接口文档的版本号
                .contact(new Contact("java2323","http://www.java.com","java192.cn"))
                .build();
    }
}
